package com.foxit.pdf2html5.progressbar;

import java.io.Serializable;
import java.util.HashMap;

import com.google.gson.Gson;


/**
 * 
 * Upload status class.
 * 
 * @author Xiangshang Yu.
 *
 */
public class FileUploadStatus implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -3926570783601356422L;
	/**
	 * the file is uploading.
	 */
	public static final int STATUS_UPLOADING = 0;
	/**
	 * Upload file failed.
	 */
	public static final int STATUS_FAILED = 1;
	/**
	 * Upload file finished.
	 */
	public static final int STATUS_FINISHED = 2;
	

	/**
	 * bytes has been read.
	 */
	private long readedBytes = 0L;
	/**
	 * total bytes of the file.
	 */
	private long totalBytes = 0L;
	private int currentItem = 0;
	/**
	 * current status of uploading.
	 */
	private int status = STATUS_UPLOADING;
	
	public long getReadedBytes() {
		return readedBytes;
	}

	public void setReadedBytes(long readedBytes) {
		this.readedBytes = readedBytes;
	}

	public long getTotalBytes() {
		return totalBytes;
	}

	public void setTotalBytes(long totalBytes) {
		this.totalBytes = totalBytes;
	}

	public int getCurrentItem() {
		return currentItem;
	}

	public void setCurrentItem(int currentItem) {
		this.currentItem = currentItem;
	}
 
	public int getStatus() {
		return this.status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String toJSon() {
		HashMap<String,Object> map=new HashMap<String,Object>();
		map.put("status", this.status);
		map.put("readedBytes",readedBytes+"");
		map.put("totalBytes", totalBytes+"");
		map.put("currentItem", currentItem+"");
		Gson gson = new Gson();
		return gson.toJson(map).toString();
	}	
}
